<!-- build time:Sun Nov 24 2019 22:25:20 GMT+0800 (China Standard Time) --><!DOCTYPE html><html lang="zh"><head><meta charset="utf-8"><title>Python面向对象基础 - Note?Note!</title><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"><meta name="description" content="类的定义类的定义的语法123456class ClassName:    &amp;lt;statement-1&amp;gt;    ...    ...    ...    &amp;lt;statement-N&amp;gt;"><meta name="keywords" content="Python,OOP"><meta property="og:type" content="article"><meta property="og:title" content="Python面向对象基础"><meta property="og:url" content="http:&#x2F;&#x2F;www.borgor.cn&#x2F;2017-09-04&#x2F;c0566d40.html"><meta property="og:site_name" content="Note?Note!"><meta property="og:description" content="类的定义类的定义的语法123456class ClassName:    &amp;lt;statement-1&amp;gt;    ...    ...    ...    &amp;lt;statement-N&amp;gt;"><meta property="og:locale" content="zh-CN"><meta property="og:image" content="https:&#x2F;&#x2F;imgs.borgor.cn&#x2F;imgs20190625084015.png"><meta property="og:updated_time" content="2019-10-08T06:16:25.000Z"><meta name="twitter:card" content="summary"><meta name="twitter:image" content="https:&#x2F;&#x2F;imgs.borgor.cn&#x2F;imgs20190625084015.png"><link rel="icon" href="/favicon.ico"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css"><link rel="stylesheet" href="https://cdnjs.loli.net/ajax/libs/font-awesome/5.4.1/css/all.min.css"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,600|Source+Code+Pro"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-light.min.css"><style>body>.footer,body>.navbar,body>.section{opacity:0}</style><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.6.8/css/lightgallery.min.css"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/justifiedGallery/3.7.0/css/justifiedGallery.min.css"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.css"><link rel="stylesheet" href="/css/back-to-top.css"><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="//hm.baidu.com/hm.js?6cecff6d18ae0c22fd7ac294c80fe7c0";var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(e,c)}()</script><link rel="stylesheet" href="/css/progressbar.css"><script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js"></script><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><link rel="stylesheet" href="/css/style.css"></head><body class="is-2-column"><nav class="navbar navbar-main"><div class="container"><div class="navbar-brand is-flex-center"><a class="navbar-item navbar-logo" href="/"><img src="https://imgs.borgor.cn/imgs20190625111723.jpg" alt="Python面向对象基础" height="28"></a></div><div class="navbar-menu"><div class="navbar-start"><a class="navbar-item" href="/">首页</a> <a class="navbar-item" href="/archives">归档</a> <a class="navbar-item" href="/categories">分类</a> <a class="navbar-item" href="/tags">标签</a> <a class="navbar-item" href="/readinglist">书单</a></div><div class="navbar-end"><a class="navbar-item is-hidden-tablet catalogue" title="目录" href="javascript:;" target="_blank" rel="noopener"><i class="fas fa-list-ul"></i> </a><a class="navbar-item search" title="搜索" href="javascript:;" target="_blank" rel="noopener"><i class="fas fa-search"></i></a></div></div></div></nav><section class="section"><div class="container"><div class="columns"><div class="column is-8-tablet is-9-desktop is-9-widescreen has-order-2 column-main"><div class="card"><div class="card-image"><span class="image is-7by1"><img class="thumbnail" src="https://imgs.borgor.cn/imgs20190625084015.png" alt="Python面向对象基础"></span></div><div class="card-content article"><div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto"><div class="level-left"><time class="level-item has-text-grey" datetime="2017-09-03T16:00:00.000Z">2017-09-04</time><div class="level-item"><a class="has-link-grey -link" href="/categories/Development/">Development</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/Development/Python/">Python</a></div><span class="level-item has-text-grey">25 分钟 读完 (大约 3768 个字) </span><span class="level-item has-text-grey" id="busuanzi_container_page_pv"><i class="far fa-eye"></i> <span id="busuanzi_value_page_pv">0</span>次访问</span></div></div><h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">Python面向对象基础</h1><div class="content"><h1 id="类的定义"><a href="#类的定义" class="headerlink" title="类的定义"></a>类的定义</h1><p>类的定义的语法</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">class ClassName:</span><br><span class="line">    &lt;statement-1&gt;</span><br><span class="line">    ...</span><br><span class="line">    ...</span><br><span class="line">    ...</span><br><span class="line">    &lt;statement-N&gt;</span><br></pre></td></tr></table></figure><a id="more"></a><p>示例代码</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">class Door:</span><br><span class="line">    def __init__(self, number, status):</span><br><span class="line">        self.number = number</span><br><span class="line">        self.status = status</span><br></pre></td></tr></table></figure><h1 id="类的实例化"><a href="#类的实例化" class="headerlink" title="类的实例化"></a>类的实例化</h1><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">class Door:</span><br><span class="line">    def __init__(self, number, status):</span><br><span class="line">        self.number = number</span><br><span class="line">        self.status = status</span><br><span class="line"></span><br><span class="line">door = Door(1001, &apos;open&apos;)</span><br><span class="line">door.number</span><br><span class="line">door.status</span><br></pre></td></tr></table></figure><ul><li>创建对象使用<code>类名(__init__ 函数除第一个参数外的参数列表)</code></li><li>创建对象的时候实际执行了 <code>__init__</code>函数</li><li><code>__init__</code> 函数并不会创建对象</li></ul><p>函数创建及初始化的过程</p><ol><li>首先创建对象</li><li>对象作为self参数传递给<code>__init__</code>函数</li><li>返回self</li></ol><h1 id="作用域"><a href="#作用域" class="headerlink" title="作用域"></a>作用域</h1><h2 id="类变量"><a href="#类变量" class="headerlink" title="类变量"></a>类变量</h2><p>示例代码</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line">In [1]: class A:</span><br><span class="line">   ...:         NAME = &apos;A&apos;  # 类的直接下级作用域 叫做类变量</span><br><span class="line">   ...:         def __init__(self, name):</span><br><span class="line">   ...:             self.name = name  # 关联到实例的变量 叫做实例变量</span><br><span class="line">   ...:          </span><br><span class="line"></span><br><span class="line">In [2]: a = A(&apos;a&apos;)</span><br><span class="line"></span><br><span class="line">In [3]: a.NAME</span><br><span class="line">Out[3]: &apos;A&apos;</span><br><span class="line"></span><br><span class="line">In [4]: a.name</span><br><span class="line">Out[4]: &apos;a&apos;</span><br><span class="line"></span><br><span class="line">In [5]: A.NAME</span><br><span class="line">Out[5]: &apos;A&apos;</span><br><span class="line"></span><br><span class="line">In [6]: A.name</span><br><span class="line">---------------------------------------------------------------------------</span><br><span class="line">AttributeError                            Traceback (most recent call last)</span><br><span class="line">&lt;ipython-input-6-61c1cc534250&gt; in &lt;module&gt;()</span><br><span class="line">----&gt; 1 A.name</span><br><span class="line"></span><br><span class="line">AttributeError: type object &apos;A&apos; has no attribute &apos;name&apos;</span><br><span class="line"></span><br><span class="line">In [7]: a2 = A(&apos;a2&apos;)</span><br><span class="line"></span><br><span class="line">In [8]: a2.NAME</span><br><span class="line">Out[8]: &apos;A&apos;</span><br><span class="line"></span><br><span class="line">In [9]: a2.NAME = &apos;A2&apos;  # 给示例a2的类变量NAME赋值</span><br><span class="line"></span><br><span class="line">In [10]: a2.NAME</span><br><span class="line">Out[10]: &apos;A2&apos;</span><br><span class="line"></span><br><span class="line">In [11]: a.NAME</span><br><span class="line">Out[11]: &apos;A&apos;</span><br><span class="line"></span><br><span class="line">In [12]: A.NAME  # 类变量没有变化</span><br><span class="line">Out[12]: &apos;A&apos;</span><br><span class="line"></span><br><span class="line">In [13]: a2.xxx = 3</span><br><span class="line"></span><br><span class="line">In [14]: a2.xxx  # 赋值之后a2多了xxx属性</span><br><span class="line">Out[14]: 3</span><br><span class="line"></span><br><span class="line">In [15]: A.NAME = &apos;AA&apos;  # 直接修改类的类变量</span><br><span class="line"></span><br><span class="line">In [16]: A.NAME</span><br><span class="line">Out[16]: &apos;AA&apos;</span><br><span class="line"></span><br><span class="line">In [17]: a.NAME  # 对应的实例的类变量也发生了改变</span><br><span class="line">Out[17]: &apos;AA&apos;</span><br><span class="line"></span><br><span class="line">In [18]: a2.NAME  # a2的类变量在之前的赋值被覆盖了，因此改变类变量的并不会影响a2</span><br><span class="line">Out[18]: &apos;A2&apos;</span><br></pre></td></tr></table></figure><p>所以</p><ul><li>类变量对类和实例都可见</li><li>所有实例共享类变量</li><li>当给实例的类变量赋值时，相当于动态的给这个实例增加了一个属性，覆盖了类变量</li></ul><h2 id="属性查找顺序"><a href="#属性查找顺序" class="headerlink" title="属性查找顺序"></a>属性查找顺序</h2><ul><li><code>__dict__</code>： 实例变量的字典</li><li><code>__class__</code>： 得到实例对应的类</li><li>先查找<code>__dict__</code>在查找<code>__class__</code></li></ul><p>代码</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">In [1]: class A:</span><br><span class="line">   ...:     NAME = &apos;A&apos;</span><br><span class="line">   ...:     def __init__(self, name):</span><br><span class="line">   ...:         self.name = name</span><br><span class="line">   ...:         </span><br><span class="line"></span><br><span class="line">In [2]: a = A(&apos;a&apos;)</span><br><span class="line"></span><br><span class="line">In [3]: a.NAME</span><br><span class="line">Out[3]: &apos;A&apos;</span><br><span class="line"></span><br><span class="line">In [4]: a.__class__.NAME</span><br><span class="line">Out[4]: &apos;A&apos;</span><br><span class="line"></span><br><span class="line">In [5]: a.__dict__</span><br><span class="line">Out[5]: &#123;&apos;name&apos;: &apos;a&apos;&#125;</span><br><span class="line"></span><br><span class="line">In [6]: a.__class__  # a.__class__表示实例对应的类</span><br><span class="line">Out[6]: __main__.A</span><br><span class="line"></span><br><span class="line">In [7]: a.NAME = &apos;AA&apos;</span><br><span class="line"></span><br><span class="line">In [8]: a.__dict__  # 覆盖类变量之后__dict__增加了一个键值对</span><br><span class="line">Out[8]: &#123;&apos;NAME&apos;: &apos;AA&apos;, &apos;name&apos;: &apos;a&apos;&#125;</span><br><span class="line"></span><br><span class="line">In [9]: a.__dict__[&apos;NAME&apos;] = &apos;AAA&apos;  # 可以直接修改__dict__</span><br><span class="line"></span><br><span class="line">In [10]: a.__dict__</span><br><span class="line">Out[10]: &#123;&apos;NAME&apos;: &apos;AAA&apos;, &apos;name&apos;: &apos;a&apos;&#125;</span><br><span class="line"></span><br><span class="line">In [11]: a.__class__.NAME</span><br><span class="line">Out[11]: &apos;A&apos;</span><br><span class="line"></span><br><span class="line">In [12]: a.__class__.__dict__</span><br><span class="line">Out[12]: </span><br><span class="line">mappingproxy(&#123;&apos;NAME&apos;: &apos;A&apos;,</span><br><span class="line">              &apos;__dict__&apos;: &lt;attribute &apos;__dict__&apos; of &apos;A&apos; objects&gt;,</span><br><span class="line">              &apos;__doc__&apos;: None,</span><br><span class="line">              &apos;__init__&apos;: &lt;function __main__.A.__init__&gt;,</span><br><span class="line">              &apos;__module__&apos;: &apos;__main__&apos;,</span><br><span class="line">              &apos;__weakref__&apos;: &lt;attribute &apos;__weakref__&apos; of &apos;A&apos; objects&gt;&#125;)</span><br></pre></td></tr></table></figure><h2 id="类装饰器"><a href="#类装饰器" class="headerlink" title="类装饰器"></a>类装饰器</h2><p>参数是一个类，并且返回一个类的函数就可以是一个类装饰器。</p><p>类装饰器通常用于给类增加属性，如果增加方法，则都是类级的方法。</p><p><strong>代码1：给类增加属性</strong></p><p>函数方法增加：定义set_name函数给类F增加一个NAME属性</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">In [1]: class F:</span><br><span class="line">   ...:     pass</span><br><span class="line">   ...: </span><br><span class="line"></span><br><span class="line">In [2]: def set_name(cls, name):  # 给cls增加属性NAME=name</span><br><span class="line">   ...:     cls.NAME = name</span><br><span class="line">   ...:     return cls</span><br><span class="line">   ...: </span><br><span class="line"></span><br><span class="line">In [3]: F1 = set_name(F, &apos;F&apos;)  # 返回F本身，并且F1指向F</span><br><span class="line"></span><br><span class="line">In [4]: F1.NAME</span><br><span class="line">Out[4]: &apos;F&apos;</span><br><span class="line"></span><br><span class="line">In [5]: f1 = F1()</span><br><span class="line"></span><br><span class="line">In [6]: f1.NAME</span><br><span class="line">Out[6]: &apos;F&apos;</span><br><span class="line"></span><br><span class="line">In [7]: F1.__dict__</span><br><span class="line">Out[7]: </span><br><span class="line">mappingproxy(&#123;&apos;NAME&apos;: &apos;F&apos;,</span><br><span class="line">              &apos;__dict__&apos;: &lt;attribute &apos;__dict__&apos; of &apos;F&apos; objects&gt;,</span><br><span class="line">              &apos;__doc__&apos;: None,</span><br><span class="line">              &apos;__module__&apos;: &apos;__main__&apos;,</span><br><span class="line">              &apos;__weakref__&apos;: &lt;attribute &apos;__weakref__&apos; of &apos;F&apos; objects&gt;&#125;)</span><br><span class="line"></span><br><span class="line">In [8]: f1.__dict__</span><br><span class="line">Out[8]: &#123;&#125;</span><br><span class="line"></span><br><span class="line">In [9]: f1.__class__</span><br><span class="line">Out[9]: __main__.F</span><br><span class="line"></span><br><span class="line">In [10]: F.__dict__  # 本质上增加的还是类F</span><br><span class="line">Out[10]: </span><br><span class="line">mappingproxy(&#123;&apos;NAME&apos;: &apos;F&apos;,</span><br><span class="line">              &apos;__dict__&apos;: &lt;attribute &apos;__dict__&apos; of &apos;F&apos; objects&gt;,</span><br><span class="line">              &apos;__doc__&apos;: None,</span><br><span class="line">              &apos;__module__&apos;: &apos;__main__&apos;,</span><br><span class="line">              &apos;__weakref__&apos;: &lt;attribute &apos;__weakref__&apos; of &apos;F&apos; objects&gt;&#125;)</span><br></pre></td></tr></table></figure><p>对set_name函数进行柯里化，实现带参数的类装饰器</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">In [2]: def set_name(name):   # 传入参数name</span><br><span class="line">   ...:     def wrap(cls):   # 装饰器是wrap</span><br><span class="line">   ...:         cls.NAME = name</span><br><span class="line">   ...:         return cls</span><br><span class="line">   ...:     return wrap</span><br><span class="line">   ...: </span><br><span class="line"></span><br><span class="line">In [3]: @set_name(&apos;G&apos;)</span><br><span class="line">   ...: class G:</span><br><span class="line">   ...:     pass</span><br><span class="line">   ...: </span><br><span class="line"></span><br><span class="line">In [4]: G.NAME</span><br><span class="line">Out[4]: &apos;G&apos;</span><br><span class="line"></span><br><span class="line">In [5]: class G:</span><br><span class="line">   ...:     pass</span><br><span class="line">   ...: </span><br><span class="line"></span><br><span class="line">In [6]: G = set_name(&apos;G&apos;)(G)  # 装饰器的函数调用方法</span><br><span class="line"></span><br><span class="line">In [7]: G.NAME</span><br><span class="line">Out[7]: &apos;G&apos;</span><br></pre></td></tr></table></figure><p><strong>代码2：给类增加方法</strong></p><p>类装饰器<code>get_name</code>给类H增加一个方法<code>__get_name__</code></p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">In [1]: def get_name(cls):</span><br><span class="line">   ...:     def _get_name(self):</span><br><span class="line">   ...:         return cls.__name__</span><br><span class="line">   ...:     cls.__get_name__ = _get_name  # 给cls增加__get_name__指向_get_name</span><br><span class="line">   ...:     return cls</span><br><span class="line">   ...: </span><br><span class="line"></span><br><span class="line">In [2]: @get_name</span><br><span class="line">   ...: class H:</span><br><span class="line">   ...:     pass</span><br><span class="line">   ...: </span><br><span class="line"></span><br><span class="line">In [3]: h = H()</span><br><span class="line"></span><br><span class="line">In [4]: h.__get_name__()</span><br><span class="line">Out[4]: &apos;H&apos;</span><br><span class="line"></span><br><span class="line">In [5]: H.__dict__</span><br><span class="line">Out[5]: </span><br><span class="line">mappingproxy(&#123;&apos;__dict__&apos;: &lt;attribute &apos;__dict__&apos; of &apos;H&apos; objects&gt;,</span><br><span class="line">              &apos;__doc__&apos;: None,</span><br><span class="line">              &apos;__get_name__&apos;: &lt;function __main__.get_name.&lt;locals&gt;._get_name&gt;,</span><br><span class="line">              &apos;__module__&apos;: &apos;__main__&apos;,</span><br><span class="line">              &apos;__weakref__&apos;: &lt;attribute &apos;__weakref__&apos; of &apos;H&apos; objects&gt;&#125;)</span><br></pre></td></tr></table></figure><h2 id="类方法-静态方法"><a href="#类方法-静态方法" class="headerlink" title="类方法/静态方法"></a>类方法/静态方法</h2><p>方法的定义都是类级的，但是有的方法使用实例调用，有的方法使用类来调用</p><ul><li>类方法：当一个方法，被classmethod装饰时， 第一个参数会变成类本身， 这样的方法叫类方法</li><li>当一个方法， 被staticmethod装饰的时候，不会自动传递第一个参数， 这样的方法叫静态方法</li></ul><p><strong>代码</strong></p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">class I:</span><br><span class="line">    def print(self):  # 实例方法</span><br><span class="line">        print(&apos;instance method&apos;)</span><br><span class="line"></span><br><span class="line">    @classmethod</span><br><span class="line">    def class_print(cls):  # 类方法</span><br><span class="line">        print(id(cls))</span><br><span class="line">        print(&apos;class method&apos;)</span><br><span class="line"></span><br><span class="line">    @staticmethod </span><br><span class="line">    def static_print():  # 静态方法</span><br><span class="line">        print(&apos;static method&apos;)</span><br><span class="line"></span><br><span class="line">    def xxx_print():  # 一个普通方法</span><br><span class="line">        print(&apos;this is a function&apos;)</span><br></pre></td></tr></table></figure><ul><li>实例方法只能由实例调用</li><li>类方法可以被类和实例使用，并且被实例使用时，传入的第一个参数还是类</li><li>静态方法可以被类和实例使用，都不会传入第一个参数</li><li>类中的普通方法，因为没有传入self，因此只能被类使用，实例无法使用</li><li>各种方法根据首参来决定。</li></ul><h1 id="访问控制"><a href="#访问控制" class="headerlink" title="访问控制"></a>访问控制</h1><h2 id="双下划线"><a href="#双下划线" class="headerlink" title="双下划线"></a>双下划线</h2><ul><li>所有<strong>双下划线开始，非双下划线结尾</strong>的成员，都是私有成员</li><li>严格的说， Python里没有真正私有成员</li><li>Python的私有成员是通过<strong>改名</strong>实现的：_类名 + 带双下划綫的属性</li><li><strong>除非真的有必要，并且清除明白的知道会有什么后果，否则不要通过改名规则修改私有成员</strong></li></ul><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br></pre></td><td class="code"><pre><span class="line">In [1]: class Door:</span><br><span class="line">   ...:     def __init__(self, number, status):</span><br><span class="line">   ...:         self.number = number</span><br><span class="line">   ...:         self.__status = status  # 双下划线开始， 非双下划綫结尾的都是私有的， 在类外部无法访问</span><br><span class="line">   ...:     def open(self):</span><br><span class="line">   ...:         self.__status = &apos;opening&apos;</span><br><span class="line">   ...:     def close(self):</span><br><span class="line">   ...:         self.__status = &apos;closed&apos;</span><br><span class="line">   ...:     def status(self):</span><br><span class="line">   ...:         return self.__status</span><br><span class="line">   ...:     def __set_number(self, number):  # # 双下滑先开始， 非双下划线结尾的方法也是私有方法</span><br><span class="line">   ...:         self.number = number</span><br><span class="line">   ...:         </span><br><span class="line"></span><br><span class="line">In [2]: door = Door(1001, &apos;closed&apos;)</span><br><span class="line"></span><br><span class="line">In [3]: door.__status  # 无法访问私有属性</span><br><span class="line">---------------------------------------------------------------------------</span><br><span class="line">AttributeError                            Traceback (most recent call last)</span><br><span class="line">&lt;ipython-input-3-d55234f04e7f&gt; in &lt;module&gt;()</span><br><span class="line">----&gt; 1 door.__status</span><br><span class="line"></span><br><span class="line">AttributeError: &apos;Door&apos; object has no attribute &apos;__status&apos;</span><br><span class="line"></span><br><span class="line">In [4]: door.__dict__  # door对象含有的属性_Door__status</span><br><span class="line">Out[4]: &#123;&apos;_Door__status&apos;: &apos;closed&apos;, &apos;number&apos;: 1001&#125;</span><br><span class="line"></span><br><span class="line">In [5]: door.__status = &apos;hahaha&apos;  # 给对象创建了新的属性，并没有修改到__status</span><br><span class="line"></span><br><span class="line">In [6]: door.__status</span><br><span class="line">Out[6]: &apos;hahaha&apos;</span><br><span class="line"></span><br><span class="line">In [7]: door.__dict__</span><br><span class="line">Out[7]: &#123;&apos;_Door__status&apos;: &apos;closed&apos;, &apos;__status&apos;: &apos;hahaha&apos;, &apos;number&apos;: 1001&#125;</span><br><span class="line"></span><br><span class="line">In [8]: door.status()</span><br><span class="line">Out[8]: &apos;closed&apos;</span><br><span class="line"></span><br><span class="line">In [9]: door.open()</span><br><span class="line"></span><br><span class="line">In [10]: door.status()</span><br><span class="line">Out[10]: &apos;opening&apos;</span><br><span class="line"></span><br><span class="line">In [11]: door.__set_number(1002)</span><br><span class="line">---------------------------------------------------------------------------</span><br><span class="line">AttributeError                            Traceback (most recent call last)</span><br><span class="line">&lt;ipython-input-11-888a73f63746&gt; in &lt;module&gt;()</span><br><span class="line">----&gt; 1 door.__set_number(1002)</span><br><span class="line"></span><br><span class="line">AttributeError: &apos;Door&apos; object has no attribute &apos;__set_number&apos;</span><br><span class="line"></span><br><span class="line">In [12]: door._Door__status</span><br><span class="line">Out[12]: &apos;opening&apos;</span><br><span class="line"></span><br><span class="line">In [13]: door._Door__status = &apos;hehehe&apos;  # _类名 + 带双下划綫的属性的方式直接修改私有成员</span><br><span class="line"></span><br><span class="line">In [14]: door.status()</span><br><span class="line">Out[14]: &apos;hehehe&apos;</span><br></pre></td></tr></table></figure><h2 id="单下划线"><a href="#单下划线" class="headerlink" title="单下划线"></a>单下划线</h2><ul><li>单下划线是一种惯用法， 人为标记此成员为私有， 但是解释器不不做任何处理</li></ul><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">In [1]: class A:</span><br><span class="line">   ...:     def __init__(self):</span><br><span class="line">   ...:         self._a = 3</span><br><span class="line">   ...:         </span><br><span class="line"></span><br><span class="line">In [2]: a = A()</span><br><span class="line"></span><br><span class="line">In [3]: a._a</span><br><span class="line">Out[3]: 3</span><br><span class="line"></span><br><span class="line">In [4]: a._a = 4</span><br><span class="line"></span><br><span class="line">In [5]: a._a</span><br><span class="line">Out[5]: 4</span><br><span class="line"></span><br><span class="line">In [6]: a.__dict__</span><br><span class="line">Out[6]: &#123;&apos;_a&apos;: 4&#125;</span><br></pre></td></tr></table></figure><h2 id="property装饰器"><a href="#property装饰器" class="headerlink" title="property装饰器"></a>property装饰器</h2><p><strong>引入property装饰器</strong></p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">class Door:</span><br><span class="line">    def __init__(self, number):</span><br><span class="line">        self.__number = number</span><br><span class="line"></span><br><span class="line">    def get_number(self):</span><br><span class="line">        return self.__number</span><br><span class="line"></span><br><span class="line">    def set_number(self, number):</span><br><span class="line">        self.__number = number</span><br></pre></td></tr></table></figure><p>当把<code>number</code>属性变成私有属性<code>__number</code>之后，无法直接访问得到，只能通过<code>get_number</code>和<code>set_number</code>两个函数访问<code>__number</code>属性。</p><p>如果既能限制参数访问，又可以用类似属性这样简单的方式来访问类的变量，这个时候就可以使用property装饰器了。</p><ul><li><strong>Python内置的@property装饰器就是负责把一个方法变成属性调用的</strong></li></ul><p><strong>property装饰器使用</strong></p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">class Door:</span><br><span class="line">    def __init__(self, number):</span><br><span class="line">        self.__number = number</span><br><span class="line"></span><br><span class="line">    # property 装饰器会把一个仅有self参数的函数，变成一个属性， 属性的值，为方法的返回值</span><br><span class="line">    @property</span><br><span class="line">    def number(self):</span><br><span class="line">        return self.__number</span><br><span class="line"></span><br><span class="line">    # property setter 装饰器， 可以把一个方法转化为对此赋值，但此方法有一定要求</span><br><span class="line">    # 1.同名 2.必须接收两个参数 self 和 value， value为所赋的值</span><br><span class="line">    @number.setter</span><br><span class="line">    def number(self, number):</span><br><span class="line">        self.__number = number</span><br><span class="line"></span><br><span class="line">    @number.deleter</span><br><span class="line">    def number(self):</span><br><span class="line">        print(&apos;cannot remove number property&apos;)</span><br><span class="line"></span><br><span class="line">door = Door(1001)</span><br><span class="line">door.number  # 返回1001</span><br><span class="line">door.number = 1002</span><br><span class="line">door.number  # 返回1002</span><br><span class="line">del door.number  # 输出cannot remove number property</span><br></pre></td></tr></table></figure><h1 id="继承"><a href="#继承" class="headerlink" title="继承"></a>继承</h1><h2 id="单继承"><a href="#单继承" class="headerlink" title="单继承"></a>单继承</h2><ul><li>在类名后加括号 括号中是继承列表， 称之为父类或者基类或者超类</li><li>继承一个明显的好处就是可以获取父类的属性和方法</li></ul><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">class Base:</span><br><span class="line">    PUBLIC_CLASS_VAR = &apos;PUBLIC_CLASS_VAR&apos;</span><br><span class="line">    __PRIVATE_CLASS_VAR = &apos;PRIVATE_CLASS_VAR&apos;</span><br><span class="line"></span><br><span class="line">    def __init__(self):</span><br><span class="line">        self.public_instance_var = &apos;public_instance_var&apos;</span><br><span class="line">        self.__private_instance_var = &apos;private__instance_var&apos;</span><br><span class="line"></span><br><span class="line">    @classmethod</span><br><span class="line">    def public_class_method(cls):</span><br><span class="line">        return &apos;public_class_method&apos;</span><br><span class="line"></span><br><span class="line">    @classmethod</span><br><span class="line">    def __private_class_method(cls):</span><br><span class="line">        return &apos;private_class_method&apos;</span><br><span class="line"></span><br><span class="line">    @staticmethod</span><br><span class="line">    def public_static_method():</span><br><span class="line">        return &apos;public static method&apos;</span><br><span class="line"></span><br><span class="line">    @staticmethod</span><br><span class="line">    def __private_static_method():</span><br><span class="line">        return &apos;private static method&apos;</span><br><span class="line"></span><br><span class="line">    def public_instance_method(self):</span><br><span class="line">        return &apos;public_instance_method&apos;</span><br><span class="line"></span><br><span class="line">    def __private_instance_method(self):</span><br><span class="line">        return &apos;private_instance_method&apos;</span><br><span class="line"></span><br><span class="line">class Sub(Base):</span><br><span class="line">    pass</span><br><span class="line"></span><br><span class="line">sub = Sub()</span><br><span class="line">sub.__dict__</span><br><span class="line"># 输出</span><br><span class="line">&#123;&apos;_Base__private_instance_var&apos;: &apos;private__instance_var&apos;,</span><br><span class="line"> &apos;public_instance_var&apos;: &apos;public_instance_var&apos;&#125;</span><br></pre></td></tr></table></figure><ul><li>凡是公有的都能继承</li><li>凡是私有的都不能继承</li><li>原来是什么，继承过来还是什么</li></ul><h2 id="方法重写"><a href="#方法重写" class="headerlink" title="方法重写"></a>方法重写</h2><ul><li>当子类和父类有同名成员的时候， 子类的成员会覆盖父类的同名成员</li><li>当父类含有一个带参数的初始化方法的时候，子类一定需要一个初始化方法，并且在初始化方法中调用父类的初始化方法</li><li>super方法：super(type, obj) =》type:类名，obj:传递给后续方法的第一个参数</li></ul><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line">class Base:</span><br><span class="line">    def __init__(self):</span><br><span class="line">        self.__a = 4</span><br><span class="line"></span><br><span class="line">    def print(self):</span><br><span class="line">        print(&apos;Base.print&apos;)</span><br><span class="line"></span><br><span class="line">    @classmethod</span><br><span class="line">    def cls_print(cls):</span><br><span class="line">        print(&apos;Base.cls_print&apos;)</span><br><span class="line"></span><br><span class="line">class Sub(Base):</span><br><span class="line">    def print(self):  ## 当子类和父类有同名成员的时候， 子类的成员会覆盖父类的同名成员</span><br><span class="line">        print(&apos;Sub.print&apos;)</span><br><span class="line"></span><br><span class="line">    @classmethod</span><br><span class="line">    def cls_print(cls):</span><br><span class="line">        print(&apos;Sub.cls_print&apos;)</span><br><span class="line"></span><br><span class="line">    def foo(self):</span><br><span class="line">        # 调用父类的print</span><br><span class="line">        super().print()</span><br><span class="line">        # super(Sub, self).print()</span><br><span class="line"></span><br><span class="line">    @classmethod</span><br><span class="line">    def cls_foo(cls):</span><br><span class="line">        #cls.cls_print()</span><br><span class="line">        #Base.cls_print()</span><br><span class="line">        super().cls_print()</span><br><span class="line"></span><br><span class="line">class SubSub(Sub):</span><br><span class="line">    def print(self):</span><br><span class="line">        print(&apos;SubSub.print&apos;)</span><br><span class="line"></span><br><span class="line">    @classmethod</span><br><span class="line">    def cls_print(cls):</span><br><span class="line">        print(&apos;SubSub.cls_print&apos;)</span><br><span class="line"></span><br><span class="line">    def foo(self):</span><br><span class="line">        # 调用Base的print</span><br><span class="line">        super(SubSub, self).print()</span><br><span class="line">        # 代理 TYPE 的父类的方法， 并且使用 obj 绑定  第一个参数 指定调用谁的直接父类， 第二个参数指定当调用时，传递什么作为方法的第一个参数</span><br><span class="line">        super(Sub, self).print()</span><br><span class="line">        super(SubSub, SubSub).cls_print()  # 类方法的时候可以传递类，也可以传递实例self</span><br><span class="line"></span><br><span class="line">    @classmethod</span><br><span class="line">    def cls_foo(cls):</span><br><span class="line">        # Base.cls_print()</span><br><span class="line">        super(Sub, cls).cls_print()</span><br></pre></td></tr></table></figure><h2 id="多继承与MRO"><a href="#多继承与MRO" class="headerlink" title="多继承与MRO"></a>多继承与MRO</h2><h3 id="等效的类定义"><a href="#等效的类定义" class="headerlink" title="等效的类定义"></a>等效的类定义</h3><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">class A:</span><br><span class="line">    pass</span><br><span class="line"></span><br><span class="line">class A(object):</span><br><span class="line">    pass</span><br><span class="line"></span><br><span class="line">class A():</span><br><span class="line">    passs</span><br></pre></td></tr></table></figure><h3 id="多继承"><a href="#多继承" class="headerlink" title="多继承"></a>多继承</h3><ul><li>在继承列表里存在多个类的时候表示多继承</li><li>多继承会把继承列表里的所有公有成员都继承过来</li></ul><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">class A:</span><br><span class="line">    def method(self):</span><br><span class="line">        print(&apos;method of A&apos;)</span><br><span class="line"></span><br><span class="line">class B:</span><br><span class="line">    def method(self):</span><br><span class="line">        print(&apos;method of B&apos;)</span><br><span class="line"></span><br><span class="line">class C(A, B):</span><br><span class="line">    pass</span><br><span class="line"></span><br><span class="line">c = C()</span><br><span class="line">c.method()  # 输出method of A</span><br></pre></td></tr></table></figure><h3 id="MRO"><a href="#MRO" class="headerlink" title="MRO"></a>MRO</h3><p>定义一个多继承，如下</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">class A:</span><br><span class="line">    def method(self):</span><br><span class="line">        print(&apos;method of A&apos;)</span><br><span class="line"></span><br><span class="line">class B:</span><br><span class="line">    def method(self):</span><br><span class="line">        print(&apos;method of B&apos;)</span><br><span class="line"></span><br><span class="line">class C(A, B):</span><br><span class="line">    pass</span><br><span class="line"></span><br><span class="line">class E(A):</span><br><span class="line">    def method(self):</span><br><span class="line">        print(&apos;method of E&apos;)</span><br><span class="line"></span><br><span class="line">class F(E, A):</span><br><span class="line">    pass</span><br><span class="line"></span><br><span class="line">F().method()  # 输出method of E</span><br></pre></td></tr></table></figure><p>如果定义类G继承自(A, E)，如下</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">class G(A, E):  # 在定义的时候会直接报错</span><br><span class="line">    pass</span><br><span class="line"></span><br><span class="line">---------------------------------------------------------------------------</span><br><span class="line">TypeError                                 Traceback (most recent call last)</span><br><span class="line">&lt;ipython-input-51-dcac33a3d00c&gt; in &lt;module&gt;()</span><br><span class="line">----&gt; 1 class G(A, E):</span><br><span class="line">      2     pass</span><br><span class="line"></span><br><span class="line">TypeError: Cannot create a consistent method resolution</span><br><span class="line">order (MRO) for bases E, A</span><br></pre></td></tr></table></figure><p>报错显示：Cannot create a consistent method resolution order (MRO) for bases E, A</p><blockquote><p>方法解析顺序(MRO)不满足报错</p></blockquote><p><strong>分析基类E,A的MRO</strong></p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&gt;&gt;&gt; A.__mro__</span><br><span class="line">(__main__.A, object)</span><br><span class="line">&gt;&gt;&gt; E.__mro__</span><br><span class="line">(__main__.E, __main__.A, object)</span><br><span class="line">&gt;&gt;&gt; F.__mro__</span><br><span class="line">(__main__.F, __main__.E, __main__.A, object)</span><br></pre></td></tr></table></figure><p>所以，mro序列就是继承的先后顺序</p><p>那么G类的mro序列应该就是(G, A, E, object)，Python通过C3算法来确定多继承的时候是否满足<strong>mro的两个原则</strong>：</p><ol><li>本地优先： 自己定义或重写的方法优先，按照继承列表，从左到右查找</li><li>单调性：所有子类，也要满足查找顺序</li></ol><p>C3算法的主要作用是：在多继承时判断属性来自于哪个类，无法判断时抛出TypeError</p><p><strong>C3算法</strong></p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">class B(O) ：则B的mro序列为： [B, O]</span><br><span class="line">class B(A1, A2, ..., An) ：则B的mro序列为： [B] + merge(mro(A1), mro(A2), ..., mro(An), [A1, A2, ..., An, O])</span><br></pre></td></tr></table></figure><p>merge操作就是C3算法的核心，merge步骤如下：</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">* 遍历列表</span><br><span class="line">* 看第一个列表的首元素</span><br><span class="line">    * 它在其他列表中也是首元素</span><br><span class="line">    * 或者它在其他列表不存在</span><br><span class="line">* 满足以上条件，则移除该首元素，合并到mro中</span><br><span class="line">* 不满足，则抛出异常</span><br></pre></td></tr></table></figure><p><strong>C3算法分析F类的mro</strong></p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">mro(F) -&gt; [F] + merge(mro(E), mro(A), [E, A, O])</span><br><span class="line">	-&gt; [F] + merge([E, A, O], [A, O], [E, A, O])</span><br><span class="line">    -&gt; [F, E] + merge([A, O], [A, O], [A, O])</span><br><span class="line">    -&gt; [F, E, A] + merge([O], [O], [O])</span><br><span class="line">    -&gt; [F, E, A, O]</span><br></pre></td></tr></table></figure><p>merge操作成功，mro解析正确，最终mro为[F, E, A, O]</p><p><strong>C3算法分析G类的mro</strong></p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mro(G) -&gt; [G] + merge(mro(A), mro(E), [A, E, O])</span><br><span class="line">	-&gt; [G] + merge([A, O], [E, A, O], [A, E, O])</span><br><span class="line">    -&gt; raise TypeError:</span><br></pre></td></tr></table></figure><p>第一个列表的首元素为A，在第二个列表中存在但不是首元素，不满足merge的条件，直接抛出异常。</p><p><strong>结论</strong>：</p><ol><li><strong>应该尽量避免多继承</strong></li><li>多继承会对程序的心智负担造成非常大的压力</li></ol><h2 id="Mixin类"><a href="#Mixin类" class="headerlink" title="Mixin类"></a>Mixin类</h2><p>参考</p><ol><li><a href="http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014318680104044a55f4a9dbf8452caf71e8dc68b75a18000" target="_blank" rel="noopener">廖雪峰-多重继承与MixIn</a></li><li><a href="https://www.zhihu.com/question/20778853" target="_blank" rel="noopener">知乎-Mixin是什么概念?</a></li></ol><p>在编程中，mixin是指为继承自它的class提供额外的功能, 但它自身却是不单独使用的类.。在具有多继承能力的编程语言中， mixin可以为类增加额外功能或方法。</p><p>因此，MixIn模式的目的就是给一个类增加多个功能，这样，在设计类的时候，我们优先考虑通过多重继承来组合多个MixIn的功能，而不是设计多层次的复杂的继承关系。</p><p>在Python 3.5.2 源代码 socketserver.py 中的639到643行可以看到以下四个类的定义</p><figure class="highlight plain hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">class ForkingUDPServer(ForkingMixIn, UDPServer): pass</span><br><span class="line">class ForkingTCPServer(ForkingMixIn, TCPServer): pass</span><br><span class="line"></span><br><span class="line">class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass</span><br><span class="line">class ThreadingTCPServer(ThreadingMixIn, TCPServer): pass</span><br></pre></td></tr></table></figure><ul><li>BaseServer：server类的基类</li><li>UDPServer：UDP server class，继承自BaseServer</li><li>TCPServer：TCP server class，继承自BaseServer</li><li>ForkingMixIn：Mix-in class to handle each request in a new process.</li><li>ThreadingMixIn：Mix-in class to handle each request in a new thread.</li></ul><p>Python自带了<code>TCPServer</code>和<code>UDPServer</code>这两类网络服务，而要同时服务多个用户就必须使用多进程或多线程模型，这两种模型由<code>ForkingMixIn</code>和<code>ThreadingMixIn</code>提供。通过组合，就可以得到以上四个类。</p><p>可以看到，从BaseServer开始逐层继承的过程中，混入(MixIn)了ForkingMixIn类和ThreadingMixIn类。</p><p>这样的多重继承的技巧称为MixIn。</p><p>如果不采用MixIn技术，而是采用层次复杂的单继承实现，则类的数量会呈指数增长。</p><p>具体不采用MixIn技术设计的继承层次关系参见：<a href="http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014318680104044a55f4a9dbf8452caf71e8dc68b75a18000" target="_blank" rel="noopener">廖雪峰-多重继承与MixIn</a>中的Animal类的设计思路。</p><p><strong>MixIn总结</strong></p><p>MixIn其实也是一种组合的方式。通常来说，组合优于继承</p><p>Mixin 类的限制</p><ul><li>Mixin类不应该有初始化方法</li><li>Mixin类通常不能独立工作</li><li>Mixin类的祖先也应该是Mixin类</li></ul><p>通常情况下，Mixin类总在继承列表的第一位</p><div><h1>推荐文章<span style="font-size:.45em;color:gray">（由<a href="https://github.com/huiwang/hexo-recommended-posts" target="_blank" rel="noopener">hexo文章推荐插件</a>驱动）</span></h1><ul><li><a href="http://www.borgor.cn/2019-09-20/592f7ae4.html">奇异值分解的原理与使用</a></li><li><a href="http://www.borgor.cn/2019-08-25/65c8031f.html">几种使用Python绘制的HTML动态图表</a></li><li><a href="http://www.borgor.cn/2019-07-25/29fa0dd5.html">从零开始搭建CentOS+Python+nodejs开发环境</a></li><li><a href="https://abelsu7.top/2019/05/29/python-quick-reference/" target="_blank" rel="noopener">Python 速查</a></li></ul></div><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css"></div><div class="level is-size-7 is-uppercase"><div class="level-start"><div class="level-item"><span class="is-size-6 has-text-grey has-mr-7">#</span> <a class="has-link-grey -link" href="/tags/OOP/" rel="tag">OOP</a>, <a class="has-link-grey -link" href="/tags/Python/" rel="tag">Python</a></div></div></div></div></div><div class="card"><div class="card-content"><h3 class="menu-label has-text-centered">喜欢这篇文章？打赏一下作者吧</h3><div class="buttons is-centered"><a class="button is-info donate"><span class="icon is-small"><i class="fab fa-alipay"></i> </span><span>支付宝</span><div class="qrcode"><img src="https://imgs.borgor.cn/imgs20190628231540.png" alt="支付宝"></div></a><a class="button is-success donate"><span class="icon is-small"><i class="fab fa-weixin"></i> </span><span>微信</span><div class="qrcode"><img src="https://imgs.borgor.cn/imgs20190628231554.png" alt="微信"></div></a></div></div></div><div class="card card-transparent"><div class="level post-navigation is-flex-wrap is-mobile"><div class="level-start"><a class="level level-item has-link-grey article-nav-prev" href="/2017-09-06/f6088a4f.html"><i class="level-item fas fa-chevron-left"></i> <span class="level-item">在Linux上搭建TimeMachine备份服务器</span></a></div><div class="level-end"><a class="level level-item has-link-grey article-nav-next" href="/2017-09-01/fbe99afb.html"><span class="level-item">WSGI简介</span> <i class="level-item fas fa-chevron-right"></i></a></div></div></div><div class="card"><div class="card-content"><h3 class="title is-5 has-text-weight-normal">评论</h3><div id="valine-thread" class="content"></div><script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script><script src="//unpkg.com/valine/dist/Valine.min.js"></script><script>new Valine({el:"#valine-thread",notify:!1,verify:!1,app_id:"ybhyfHG9S4TQhIvstdj5pprw-gzGzoHsz",app_key:"ob8A13IBceQXqd8g92nUgNMx",placeholder:"你有想说的么？"})</script></div></div></div><div class="column is-4-tablet is-3-desktop is-3-widescreen has-order-1 column-left"><div class="card widget"><div class="card-content"><nav class="level"><div class="level-item has-text-centered"><div><figure class="image is-128x128 has-mb-6"><img class="is-rounded" src="https://imgs.borgor.cn/imgs20190625111723.jpg" alt="BorGor"></figure><p class="is-size-4 is-block">BorGor</p><p class="is-size-6 is-block">Note?Note!</p><p class="is-size-6 is-flex is-flex-center has-text-grey"><i class="fas fa-map-marker-alt has-mr-7"></i> <span>Lanzhou.Gansu</span></p></div></div></nav><nav class="level is-mobile"><div class="level-item has-text-centered is-marginless"><div><p class="heading">文章</p><p class="title has-text-weight-normal">86</p></div></div><div class="level-item has-text-centered is-marginless"><div><p class="heading">分类</p><p class="title has-text-weight-normal">26</p></div></div><div class="level-item has-text-centered is-marginless"><div><p class="heading">标签</p><p class="title has-text-weight-normal">153</p></div></div></nav><div class="level"><a class="level-item button is-link is-rounded" href="/" target="_blank">关注我</a></div><div class="level is-mobile"><a class="level-item button is-white is-marginless" target="_blank" title="Github" href="https://github.com/cyrusky"><i class="fab fa-github"></i></a></div></div></div><div class="card widget" id="toc"><div class="card-content"><div class="menu"><h3 class="menu-label">目录</h3><ul class="menu-list"><li><a class="is-flex" href="#类的定义"><span class="has-mr-6">1</span> <span>类的定义</span></a></li><li><a class="is-flex" href="#类的实例化"><span class="has-mr-6">2</span> <span>类的实例化</span></a></li><li><a class="is-flex" href="#作用域"><span class="has-mr-6">3</span> <span>作用域</span></a><ul class="menu-list"><li><a class="is-flex" href="#类变量"><span class="has-mr-6">3.1</span> <span>类变量</span></a></li><li><a class="is-flex" href="#属性查找顺序"><span class="has-mr-6">3.2</span> <span>属性查找顺序</span></a></li><li><a class="is-flex" href="#类装饰器"><span class="has-mr-6">3.3</span> <span>类装饰器</span></a></li><li><a class="is-flex" href="#类方法-静态方法"><span class="has-mr-6">3.4</span> <span>类方法/静态方法</span></a></li></ul></li><li><a class="is-flex" href="#访问控制"><span class="has-mr-6">4</span> <span>访问控制</span></a><ul class="menu-list"><li><a class="is-flex" href="#双下划线"><span class="has-mr-6">4.1</span> <span>双下划线</span></a></li><li><a class="is-flex" href="#单下划线"><span class="has-mr-6">4.2</span> <span>单下划线</span></a></li><li><a class="is-flex" href="#property装饰器"><span class="has-mr-6">4.3</span> <span>property装饰器</span></a></li></ul></li><li><a class="is-flex" href="#继承"><span class="has-mr-6">5</span> <span>继承</span></a><ul class="menu-list"><li><a class="is-flex" href="#单继承"><span class="has-mr-6">5.1</span> <span>单继承</span></a></li><li><a class="is-flex" href="#方法重写"><span class="has-mr-6">5.2</span> <span>方法重写</span></a></li><li><a class="is-flex" href="#多继承与MRO"><span class="has-mr-6">5.3</span> <span>多继承与MRO</span></a><ul class="menu-list"><li><a class="is-flex" href="#等效的类定义"><span class="has-mr-6">5.3.1</span> <span>等效的类定义</span></a></li><li><a class="is-flex" href="#多继承"><span class="has-mr-6">5.3.2</span> <span>多继承</span></a></li><li><a class="is-flex" href="#MRO"><span class="has-mr-6">5.3.3</span> <span>MRO</span></a></li></ul></li><li><a class="is-flex" href="#Mixin类"><span class="has-mr-6">5.4</span> <span>Mixin类</span></a></li></ul></li><li><a class="is-flex" href="#undefined"><span class="has-mr-6">6</span> <span>推荐文章（由hexo文章推荐插件驱动）</span></a></li></ul></div></div></div><div class="card widget"><div class="card-content"><div class="menu"><h3 class="menu-label">分类</h3><ul class="menu-list"><li><a class="level is-marginless" href="/categories/AI/"><span class="level-start"><span class="level-item">AI</span> </span><span class="level-end"><span class="level-item tag">20</span></span></a><ul><li><a class="level is-marginless" href="/categories/AI/Machine-Learning/"><span class="level-start"><span class="level-item">Machine Learning</span> </span><span class="level-end"><span class="level-item tag">6</span></span></a></li><li><a class="level is-marginless" href="/categories/AI/Mathematics/"><span class="level-start"><span class="level-item">Mathematics</span> </span><span class="level-end"><span class="level-item tag">9</span></span></a></li><li><a class="level is-marginless" href="/categories/AI/NLP/"><span class="level-start"><span class="level-item">NLP</span> </span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-marginless" href="/categories/AI/%E5%85%AC%E5%BC%8F%E6%8E%A8%E5%AF%BC/"><span class="level-start"><span class="level-item">公式推导</span> </span><span class="level-end"><span class="level-item tag">4</span></span></a></li></ul></li><li><a class="level is-marginless" href="/categories/CheatSheets/"><span class="level-start"><span class="level-item">CheatSheets</span> </span><span class="level-end"><span class="level-item tag">4</span></span></a></li><li><a class="level is-marginless" href="/categories/DevOps/"><span class="level-start"><span class="level-item">DevOps</span> </span><span class="level-end"><span class="level-item tag">8</span></span></a><ul><li><a class="level is-marginless" href="/categories/DevOps/Anti-patterns/"><span class="level-start"><span class="level-item">Anti-patterns</span> </span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-marginless" href="/categories/DevOps/Concept/"><span class="level-start"><span class="level-item">Concept</span> </span><span class="level-end"><span class="level-item tag">3</span></span></a></li><li><a class="level is-marginless" href="/categories/DevOps/Continuous-Delivery/"><span class="level-start"><span class="level-item">Continuous Delivery</span> </span><span class="level-end"><span class="level-item tag">2</span></span></a></li><li><a class="level is-marginless" href="/categories/DevOps/TeamWorks/"><span class="level-start"><span class="level-item">TeamWorks</span> </span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-marginless" href="/categories/DevOps/Testing/"><span class="level-start"><span class="level-item">Testing</span> </span><span class="level-end"><span class="level-item tag">1</span></span></a></li></ul></li><li><a class="level is-marginless" href="/categories/Development/"><span class="level-start"><span class="level-item">Development</span> </span><span class="level-end"><span class="level-item tag">33</span></span></a><ul><li><a class="level is-marginless" href="/categories/Development/Integrated/"><span class="level-start"><span class="level-item">Integrated</span> </span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-marginless" href="/categories/Development/JavaScript/"><span class="level-start"><span class="level-item">JavaScript</span> </span><span class="level-end"><span class="level-item tag">18</span></span></a></li><li><a class="level is-marginless" href="/categories/Development/Native/"><span class="level-start"><span class="level-item">Native</span> </span><span class="level-end"><span class="level-item tag">2</span></span></a></li><li><a class="level is-marginless" href="/categories/Development/Python/"><span class="level-start"><span class="level-item">Python</span> </span><span class="level-end"><span class="level-item tag">9</span></span></a></li><li><a class="level is-marginless" href="/categories/Development/React/"><span class="level-start"><span class="level-item">React</span> </span><span class="level-end"><span class="level-item tag">2</span></span></a></li><li><a class="level is-marginless" href="/categories/Development/html5/"><span class="level-start"><span class="level-item">html5</span> </span><span class="level-end"><span class="level-item tag">1</span></span></a></li></ul></li><li><a class="level is-marginless" href="/categories/Operations/"><span class="level-start"><span class="level-item">Operations</span> </span><span class="level-end"><span class="level-item tag">18</span></span></a><ul><li><a class="level is-marginless" href="/categories/Operations/Nginx/"><span class="level-start"><span class="level-item">Nginx</span> </span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-marginless" href="/categories/Operations/OpenStack/"><span class="level-start"><span class="level-item">OpenStack</span> </span><span class="level-end"><span class="level-item tag">14</span></span></a></li><li><a class="level is-marginless" href="/categories/Operations/System/"><span class="level-start"><span class="level-item">System</span> </span><span class="level-end"><span class="level-item tag">3</span></span></a></li></ul></li><li><a class="level is-marginless" href="/categories/Reading-Writing/"><span class="level-start"><span class="level-item">Reading&Writing</span> </span><span class="level-end"><span class="level-item tag">3</span></span></a><ul><li><a class="level is-marginless" href="/categories/Reading-Writing/Hexo/"><span class="level-start"><span class="level-item">Hexo</span> </span><span class="level-end"><span class="level-item tag">2</span></span></a></li><li><a class="level is-marginless" href="/categories/Reading-Writing/LaTeX/"><span class="level-start"><span class="level-item">LaTeX</span> </span><span class="level-end"><span class="level-item tag">1</span></span></a></li></ul></li></ul></div></div></div><div class="card widget"><div class="card-content"><h3 class="menu-label">标签云</h3><a href="/tags/Agile/" style="font-size:10px">Agile</a> <a href="/tags/Angularjs/" style="font-size:11.11px">Angularjs</a> <a href="/tags/Animation/" style="font-size:10px">Animation</a> <a href="/tags/Application/" style="font-size:10px">Application</a> <a href="/tags/Artificial-Intelligence/" style="font-size:10px">Artificial Intelligence</a> <a href="/tags/BP/" style="font-size:10px">BP</a> <a href="/tags/Bokeh/" style="font-size:10px">Bokeh</a> <a href="/tags/Book/" style="font-size:10px">Book</a> <a href="/tags/C4-5/" style="font-size:10px">C4.5</a> <a href="/tags/CART/" style="font-size:10px">CART</a> <a href="/tags/CD/" style="font-size:10px">CD</a> <a href="/tags/CLI/" style="font-size:10px">CLI</a> <a href="/tags/CSS/" style="font-size:10px">CSS</a> <a href="/tags/CentOS/" style="font-size:11.11px">CentOS</a> <a href="/tags/Cinder/" style="font-size:10px">Cinder</a> <a href="/tags/Clipboardjs/" style="font-size:10px">Clipboardjs</a> <a href="/tags/Concept/" style="font-size:10px">Concept</a> <a href="/tags/Continuous-Delivery/" style="font-size:10px">Continuous Delivery</a> <a href="/tags/DeepLearning/" style="font-size:16.67px">DeepLearning</a> <a href="/tags/Department/" style="font-size:11.11px">Department</a> <a href="/tags/DevOps/" style="font-size:17.78px">DevOps</a> <a href="/tags/Develop/" style="font-size:13.33px">Develop</a> <a href="/tags/Development/" style="font-size:20px">Development</a> <a href="/tags/Directive/" style="font-size:10px">Directive</a> <a href="/tags/Distribution/" style="font-size:10px">Distribution</a> <a href="/tags/Django/" style="font-size:12.22px">Django</a> <a href="/tags/Document/" style="font-size:10px">Document</a> <a href="/tags/ES5/" style="font-size:10px">ES5</a> <a href="/tags/ES6/" style="font-size:10px">ES6</a> <a href="/tags/Echarts/" style="font-size:10px">Echarts</a> <a href="/tags/Engine/" style="font-size:10px">Engine</a> <a href="/tags/Entropy/" style="font-size:10px">Entropy</a> <a href="/tags/Filter/" style="font-size:10px">Filter</a> <a href="/tags/Front-End/" style="font-size:10px">Front End</a> <a href="/tags/Gallery/" style="font-size:10px">Gallery</a> <a href="/tags/Git/" style="font-size:10px">Git</a> <a href="/tags/Gradient-descent/" style="font-size:10px">Gradient descent</a> <a href="/tags/Hexo/" style="font-size:12.22px">Hexo</a> <a href="/tags/Horizon/" style="font-size:10px">Horizon</a> <a href="/tags/ID3-5/" style="font-size:10px">ID3.5</a> <a href="/tags/Icarus/" style="font-size:10px">Icarus</a> <a href="/tags/JavaScript/" style="font-size:18.89px">JavaScript</a> <a href="/tags/Javascript/" style="font-size:11.11px">Javascript</a> <a href="/tags/KVM/" style="font-size:10px">KVM</a> <a href="/tags/LaTeX/" style="font-size:10px">LaTeX</a> <a href="/tags/LibreOffice/" style="font-size:10px">LibreOffice</a> <a href="/tags/Linux/" style="font-size:10px">Linux</a> <a href="/tags/Machine-Learning/" style="font-size:11.11px">Machine Learning</a> <a href="/tags/Matrix/" style="font-size:10px">Matrix</a> <a href="/tags/MiddleWare/" style="font-size:10px">MiddleWare</a> <a href="/tags/Module/" style="font-size:10px">Module</a> <a href="/tags/Network/" style="font-size:10px">Network</a> <a href="/tags/Nginx/" style="font-size:10px">Nginx</a> <a href="/tags/NodeJS/" style="font-size:11.11px">NodeJS</a> <a href="/tags/OOP/" style="font-size:10px">OOP</a> <a href="/tags/OpenStack/" style="font-size:17.78px">OpenStack</a> <a href="/tags/OpenStackApi/" style="font-size:14.44px">OpenStackApi</a> <a href="/tags/Operations/" style="font-size:10px">Operations</a> <a href="/tags/Oprations/" style="font-size:11.11px">Oprations</a> <a href="/tags/PDF/" style="font-size:10px">PDF</a> <a href="/tags/Pipline/" style="font-size:10px">Pipline</a> <a href="/tags/Probability/" style="font-size:12.22px">Probability</a> <a href="/tags/Python/" style="font-size:15.56px">Python</a> <a href="/tags/React/" style="font-size:11.11px">React</a> <a href="/tags/Relational-algebra/" style="font-size:10px">Relational algebra</a> <a href="/tags/Restful/" style="font-size:10px">Restful</a> <a href="/tags/Route/" style="font-size:10px">Route</a> <a href="/tags/SVD/" style="font-size:10px">SVD</a> <a href="/tags/SVM/" style="font-size:11.11px">SVM</a> <a href="/tags/Scalar/" style="font-size:10px">Scalar</a> <a href="/tags/Sigmoid/" style="font-size:10px">Sigmoid</a> <a href="/tags/Team/" style="font-size:10px">Team</a> <a href="/tags/Tempest/" style="font-size:10px">Tempest</a> <a href="/tags/Tensor/" style="font-size:10px">Tensor</a> <a href="/tags/Testing/" style="font-size:10px">Testing</a> <a href="/tags/Time/" style="font-size:10px">Time</a> <a href="/tags/TimeMachine/" style="font-size:10px">TimeMachine</a> <a href="/tags/Tips/" style="font-size:10px">Tips</a> <a href="/tags/Vector/" style="font-size:10px">Vector</a> <a href="/tags/Vmware/" style="font-size:10px">Vmware</a> <a href="/tags/Vue/" style="font-size:17.78px">Vue</a> <a href="/tags/Vuex/" style="font-size:10px">Vuex</a> <a href="/tags/WSGI/" style="font-size:10px">WSGI</a> <a href="/tags/Web/" style="font-size:10px">Web</a> <a href="/tags/Word-Cut/" style="font-size:10px">Word Cut</a> <a href="/tags/aliyun/" style="font-size:10px">aliyun</a> <a href="/tags/auth/" style="font-size:10px">auth</a> <a href="/tags/babel/" style="font-size:10px">babel</a> <a href="/tags/certbot/" style="font-size:10px">certbot</a> <a href="/tags/decision-tree/" style="font-size:10px">decision tree</a> <a href="/tags/homebrew/" style="font-size:10px">homebrew</a> <a href="/tags/jwt/" style="font-size:10px">jwt</a> <a href="/tags/keystone/" style="font-size:11.11px">keystone</a> <a href="/tags/loader/" style="font-size:10px">loader</a> <a href="/tags/mathematics/" style="font-size:11.11px">mathematics</a> <a href="/tags/migrate/" style="font-size:10px">migrate</a> <a href="/tags/openstack/" style="font-size:10px">openstack</a> <a href="/tags/pdf2html/" style="font-size:10px">pdf2html</a> <a href="/tags/pm2/" style="font-size:10px">pm2</a> <a href="/tags/singular-value-decomposition/" style="font-size:10px">singular value decomposition</a> <a href="/tags/vue-router/" style="font-size:11.11px">vue-router</a> <a href="/tags/vue-ssr/" style="font-size:10px">vue-ssr</a> <a href="/tags/webpack/" style="font-size:10px">webpack</a> <a href="/tags/%E4%BD%8E%E9%80%9A%E6%BB%A4%E6%B3%A2%E5%99%A8/" style="font-size:10px">低通滤波器</a> <a href="/tags/%E5%85%A5%E9%97%A8/" style="font-size:10px">入门</a> <a href="/tags/%E5%85%A8%E5%B1%80%E5%8F%98%E9%87%8F/" style="font-size:10px">全局变量</a> <a href="/tags/%E5%85%A8%E5%B1%80%E5%AF%B9%E8%B1%A1/" style="font-size:10px">全局对象</a> <a href="/tags/%E5%85%A8%E6%A0%88/" style="font-size:10px">全栈</a> <a href="/tags/%E5%85%AC%E5%BC%8F/" style="font-size:12.22px">公式</a> <a href="/tags/%E5%86%B3%E7%AD%96%E6%A0%91/" style="font-size:10px">决策树</a> <a href="/tags/%E5%87%BD%E6%95%B0/" style="font-size:10px">函数</a> <a href="/tags/%E5%88%86%E7%B1%BB%E5%99%A8/" style="font-size:10px">分类器</a> <a href="/tags/%E5%8A%A0%E9%80%9F/" style="font-size:10px">加速</a> <a href="/tags/%E5%8C%B9%E9%85%8D%E6%BB%A4%E6%B3%A2%E8%BE%B9%E7%BC%98%E6%A3%80%E6%B5%8B/" style="font-size:10px">匹配滤波边缘检测</a> <a href="/tags/%E5%8D%B7%E7%A7%AF/" style="font-size:10px">卷积</a> <a href="/tags/%E5%8D%B7%E7%A7%AF%E6%A0%B8/" style="font-size:10px">卷积核</a> <a href="/tags/%E5%8E%9F%E5%9E%8B%E9%93%BE/" style="font-size:10px">原型链</a> <a href="/tags/%E5%8F%8D%E5%90%91%E4%BC%A0%E6%92%AD/" style="font-size:10px">反向传播</a> <a href="/tags/%E5%8F%98%E9%87%8F%E7%B1%BB%E5%9E%8B/" style="font-size:10px">变量类型</a> <a href="/tags/%E5%AE%98%E6%96%B9%E7%A4%BA%E4%BE%8B/" style="font-size:10px">官方示例</a> <a href="/tags/%E5%AF%B9%E5%81%B6%E5%BD%A2%E5%BC%8F/" style="font-size:10px">对偶形式</a> <a href="/tags/%E5%AF%B9%E8%B1%A1/" style="font-size:10px">对象</a> <a href="/tags/%E5%B9%B3%E7%A7%BB%E5%92%8C%E6%9F%A5%E5%88%86%E8%BE%B9%E7%BC%98%E6%A3%80%E6%B5%8B/" style="font-size:10px">平移和查分边缘检测</a> <a href="/tags/%E6%8B%89%E6%A0%BC%E6%9C%97%E6%97%A5%E4%B9%98%E5%AD%90%E6%B3%95/" style="font-size:10px">拉格朗日乘子法</a> <a href="/tags/%E6%8E%A8%E5%AF%BC/" style="font-size:12.22px">推导</a> <a href="/tags/%E6%8F%90%E4%BA%A4%E9%98%B6%E6%AE%B5/" style="font-size:10px">提交阶段</a> <a href="/tags/%E6%9C%80%E5%A4%A7%E4%BC%BC%E7%84%B6%E4%BC%B0%E8%AE%A1/" style="font-size:10px">最大似然估计</a> <a href="/tags/%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E4%BC%B0%E8%AE%A1/" style="font-size:10px">最小二乘估计</a> <a href="/tags/%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95/" style="font-size:10px">最小二乘法</a> <a href="/tags/%E6%9C%B4%E7%B4%A0%E8%B4%9D%E5%8F%B6%E6%96%AF/" style="font-size:10px">朴素贝叶斯</a> <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/" style="font-size:10px">机器学习</a> <a href="/tags/%E6%9D%A1%E4%BB%B6%E6%A6%82%E7%8E%87/" style="font-size:10px">条件概率</a> <a href="/tags/%E6%A2%AF%E5%BA%A6%E4%B8%8B%E9%99%8D/" style="font-size:11.11px">梯度下降</a> <a href="/tags/%E6%A2%AF%E5%BA%A6%E6%96%B9%E5%90%91%E8%BE%B9%E7%BC%98%E6%A3%80%E6%B5%8B/" style="font-size:10px">梯度方向边缘检测</a> <a href="/tags/%E6%A6%82%E5%BF%B5/" style="font-size:10px">概念</a> <a href="/tags/%E6%A6%82%E7%8E%87/" style="font-size:10px">概率</a> <a href="/tags/%E6%B1%82%E5%AF%BC/" style="font-size:10px">求导</a> <a href="/tags/%E6%B5%81%E7%A8%8B/" style="font-size:10px">流程</a> <a href="/tags/%E7%86%B5/" style="font-size:10px">熵</a> <a href="/tags/%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/" style="font-size:10px">生命周期</a> <a href="/tags/%E7%9F%A9%E9%98%B5/" style="font-size:10px">矩阵</a> <a href="/tags/%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/" style="font-size:10px">神经网络</a> <a href="/tags/%E7%A7%81%E6%9C%89%E5%AF%B9%E8%B1%A1/" style="font-size:10px">私有对象</a> <a href="/tags/%E7%B1%BB/" style="font-size:10px">类</a> <a href="/tags/%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92/" style="font-size:10px">线性回归</a> <a href="/tags/%E8%81%94%E5%90%88%E6%A6%82%E7%8E%87/" style="font-size:10px">联合概率</a> <a href="/tags/%E8%B4%9D%E5%8F%B6%E6%96%AF%E5%88%A4%E5%AE%9A%E5%87%86%E5%88%99/" style="font-size:10px">贝叶斯判定准则</a> <a href="/tags/%E8%BE%B9%E7%BC%98%E6%A3%80%E6%B5%8B/" style="font-size:10px">边缘检测</a> <a href="/tags/%E8%BE%B9%E9%99%85%E6%A6%82%E7%8E%87/" style="font-size:10px">边际概率</a> <a href="/tags/%E9%97%AD%E5%8C%85/" style="font-size:10px">闭包</a> <a href="/tags/%E9%97%B4%E9%9A%94/" style="font-size:11.11px">间隔</a> <a href="/tags/%E9%AB%98%E6%96%AF%E5%88%86%E5%B8%83/" style="font-size:10px">高斯分布</a> <a href="/tags/%E9%AB%98%E9%80%9A%E6%BB%A4%E6%B3%A2%E5%99%A8/" style="font-size:10px">高通滤波器</a></div></div><div class="column-right-shadow"><div class="card widget"><div class="card-content"><h3 class="menu-label">最新文章</h3><article class="media"><a href="/2019-11-24/4adcf99c.html" class="media-left"><p class="image is-64x64"><img class="thumbnail" src="https://imgs.borgor.cn/imgs/20191124220507.png" alt="JavaScript闭包到底解决了什么问题？"></p></a><div class="media-content"><div class="content"><div><time class="has-text-grey is-size-7 is-uppercase" datetime="2019-11-24T12:42:13.000Z">2019-11-24</time></div><a href="/2019-11-24/4adcf99c.html" class="has-link-black-ter is-size-6">JavaScript闭包到底解决了什么问题？</a><p class="is-size-7 is-uppercase"><a class="has-link-grey -link" href="/categories/Development/">Development</a> / <a class="has-link-grey -link" href="/categories/Development/JavaScript/">JavaScript</a></p></div></div></article><article class="media"><a href="/2019-11-22/f971e187.html" class="media-left"><p class="image is-64x64"><img class="thumbnail" src="https://imgs.borgor.cn/imgs/20191122161153.png" alt="JavaScript中对象的生命周期"></p></a><div class="media-content"><div class="content"><div><time class="has-text-grey is-size-7 is-uppercase" datetime="2019-11-22T06:04:32.000Z">2019-11-22</time></div><a href="/2019-11-22/f971e187.html" class="has-link-black-ter is-size-6">JavaScript中对象的生命周期</a><p class="is-size-7 is-uppercase"><a class="has-link-grey -link" href="/categories/Development/">Development</a> / <a class="has-link-grey -link" href="/categories/Development/JavaScript/">JavaScript</a></p></div></div></article><article class="media"><a href="/2019-11-21/c07cc943.html" class="media-left"><p class="image is-64x64"><img class="thumbnail" src="https://imgs.borgor.cn/imgs/20191121175758.png" alt="React官方示例中的小游戏示例"></p></a><div class="media-content"><div class="content"><div><time class="has-text-grey is-size-7 is-uppercase" datetime="2019-11-21T09:56:03.000Z">2019-11-21</time></div><a href="/2019-11-21/c07cc943.html" class="has-link-black-ter is-size-6">React官方示例中的小游戏示例</a><p class="is-size-7 is-uppercase"><a class="has-link-grey -link" href="/categories/Development/">Development</a> / <a class="has-link-grey -link" href="/categories/Development/React/">React</a></p></div></div></article><article class="media"><a href="/2019-11-21/769edcc6.html" class="media-left"><p class="image is-64x64"><img class="thumbnail" src="https://imgs.borgor.cn/imgs/20191121141128.png" alt="JavaScript引擎的工作原理探析"></p></a><div class="media-content"><div class="content"><div><time class="has-text-grey is-size-7 is-uppercase" datetime="2019-11-21T00:30:12.000Z">2019-11-21</time></div><a href="/2019-11-21/769edcc6.html" class="has-link-black-ter is-size-6">JavaScript引擎的工作原理探析</a><p class="is-size-7 is-uppercase"><a class="has-link-grey -link" href="/categories/Development/">Development</a> / <a class="has-link-grey -link" href="/categories/Development/JavaScript/">JavaScript</a></p></div></div></article><article class="media"><a href="/2019-11-19/290f6390.html" class="media-left"><p class="image is-64x64"><img class="thumbnail" src="https://imgs.borgor.cn/imgs/20191119100237.png" alt="深入了解JavaScript中的基本变量类型"></p></a><div class="media-content"><div class="content"><div><time class="has-text-grey is-size-7 is-uppercase" datetime="2019-11-19T04:22:33.000Z">2019-11-19</time></div><a href="/2019-11-19/290f6390.html" class="has-link-black-ter is-size-6">深入了解JavaScript中的基本变量类型</a><p class="is-size-7 is-uppercase"><a class="has-link-grey -link" href="/categories/Development/">Development</a> / <a class="has-link-grey -link" href="/categories/Development/JavaScript/">JavaScript</a></p></div></div></article></div></div><div class="card widget"><div class="card-content"><div class="menu"><h3 class="menu-label">归档</h3><ul class="menu-list"><li><a class="level is-marginless" href="/archives/2019/11/"><span class="level-start"><span class="level-item">十一月 2019</span> </span><span class="level-end"><span class="level-item tag">7</span></span></a></li><li><a class="level is-marginless" href="/archives/2019/10/"><span class="level-start"><span class="level-item">十月 2019</span> </span><span class="level-end"><span class="level-item tag">8</span></span></a></li><li><a class="level is-marginless" href="/archives/2019/09/"><span class="level-start"><span class="level-item">九月 2019</span> </span><span class="level-end"><span class="level-item tag">5</span></span></a></li><li><a class="level is-marginless" href="/archives/2019/08/"><span class="level-start"><span class="level-item">八月 2019</span> </span><span class="level-end"><span class="level-item tag">13</span></span></a></li><li><a class="level is-marginless" href="/archives/2019/07/"><span class="level-start"><span class="level-item">七月 2019</span> </span><span class="level-end"><span class="level-item tag">15</span></span></a></li><li><a class="level is-marginless" href="/archives/2019/06/"><span class="level-start"><span class="level-item">六月 2019</span> </span><span class="level-end"><span class="level-item tag">11</span></span></a></li><li><a class="level is-marginless" href="/archives/2018/07/"><span class="level-start"><span class="level-item">七月 2018</span> </span><span class="level-end"><span class="level-item tag">4</span></span></a></li><li><a class="level is-marginless" href="/archives/2018/06/"><span class="level-start"><span class="level-item">六月 2018</span> </span><span class="level-end"><span class="level-item tag">3</span></span></a></li><li><a class="level is-marginless" href="/archives/2017/12/"><span class="level-start"><span class="level-item">十二月 2017</span> </span><span class="level-end"><span class="level-item tag">2</span></span></a></li><li><a class="level is-marginless" href="/archives/2017/11/"><span class="level-start"><span class="level-item">十一月 2017</span> </span><span class="level-end"><span class="level-item tag">3</span></span></a></li><li><a class="level is-marginless" href="/archives/2017/10/"><span class="level-start"><span class="level-item">十月 2017</span> </span><span class="level-end"><span class="level-item tag">5</span></span></a></li><li><a class="level is-marginless" href="/archives/2017/09/"><span class="level-start"><span class="level-item">九月 2017</span> </span><span class="level-end"><span class="level-item tag">10</span></span></a></li></ul></div></div></div><div class="card widget"><div class="card-content"><div class="menu"><h3 class="menu-label">标签</h3><div class="field is-grouped is-grouped-multiline"><div class="control"><a class="tags has-addons" href="/tags/Agile/"><span class="tag">Agile</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Angularjs/"><span class="tag">Angularjs</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Animation/"><span class="tag">Animation</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Application/"><span class="tag">Application</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Artificial-Intelligence/"><span class="tag">Artificial Intelligence</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/BP/"><span class="tag">BP</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Bokeh/"><span class="tag">Bokeh</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Book/"><span class="tag">Book</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/C4-5/"><span class="tag">C4.5</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/CART/"><span class="tag">CART</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/CD/"><span class="tag">CD</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/CLI/"><span class="tag">CLI</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/CSS/"><span class="tag">CSS</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/CentOS/"><span class="tag">CentOS</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Cinder/"><span class="tag">Cinder</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Clipboardjs/"><span class="tag">Clipboardjs</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Concept/"><span class="tag">Concept</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Continuous-Delivery/"><span class="tag">Continuous Delivery</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/DeepLearning/"><span class="tag">DeepLearning</span> <span class="tag is-grey">7</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Department/"><span class="tag">Department</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/DevOps/"><span class="tag">DevOps</span> <span class="tag is-grey">8</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Develop/"><span class="tag">Develop</span> <span class="tag is-grey">4</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Development/"><span class="tag">Development</span> <span class="tag is-grey">16</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Directive/"><span class="tag">Directive</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Distribution/"><span class="tag">Distribution</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Django/"><span class="tag">Django</span> <span class="tag is-grey">3</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Document/"><span class="tag">Document</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/ES5/"><span class="tag">ES5</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/ES6/"><span class="tag">ES6</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Echarts/"><span class="tag">Echarts</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Engine/"><span class="tag">Engine</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Entropy/"><span class="tag">Entropy</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Filter/"><span class="tag">Filter</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Front-End/"><span class="tag">Front End</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Gallery/"><span class="tag">Gallery</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Git/"><span class="tag">Git</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Gradient-descent/"><span class="tag">Gradient descent</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Hexo/"><span class="tag">Hexo</span> <span class="tag is-grey">3</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Horizon/"><span class="tag">Horizon</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/ID3-5/"><span class="tag">ID3.5</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Icarus/"><span class="tag">Icarus</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/JavaScript/"><span class="tag">JavaScript</span> <span class="tag is-grey">9</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Javascript/"><span class="tag">Javascript</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/KVM/"><span class="tag">KVM</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/LaTeX/"><span class="tag">LaTeX</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/LibreOffice/"><span class="tag">LibreOffice</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Linux/"><span class="tag">Linux</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Machine-Learning/"><span class="tag">Machine Learning</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Matrix/"><span class="tag">Matrix</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/MiddleWare/"><span class="tag">MiddleWare</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Module/"><span class="tag">Module</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Network/"><span class="tag">Network</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Nginx/"><span class="tag">Nginx</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/NodeJS/"><span class="tag">NodeJS</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/OOP/"><span class="tag">OOP</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/OpenStack/"><span class="tag">OpenStack</span> <span class="tag is-grey">8</span></a></div><div class="control"><a class="tags has-addons" href="/tags/OpenStackApi/"><span class="tag">OpenStackApi</span> <span class="tag is-grey">5</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Operations/"><span class="tag">Operations</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Oprations/"><span class="tag">Oprations</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/PDF/"><span class="tag">PDF</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Pipline/"><span class="tag">Pipline</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Probability/"><span class="tag">Probability</span> <span class="tag is-grey">3</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Python/"><span class="tag">Python</span> <span class="tag is-grey">6</span></a></div><div class="control"><a class="tags has-addons" href="/tags/React/"><span class="tag">React</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Relational-algebra/"><span class="tag">Relational algebra</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Restful/"><span class="tag">Restful</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Route/"><span class="tag">Route</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/SVD/"><span class="tag">SVD</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/SVM/"><span class="tag">SVM</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Scalar/"><span class="tag">Scalar</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Sigmoid/"><span class="tag">Sigmoid</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Team/"><span class="tag">Team</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Tempest/"><span class="tag">Tempest</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Tensor/"><span class="tag">Tensor</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Testing/"><span class="tag">Testing</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Time/"><span class="tag">Time</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/TimeMachine/"><span class="tag">TimeMachine</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Tips/"><span class="tag">Tips</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Vector/"><span class="tag">Vector</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Vmware/"><span class="tag">Vmware</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Vue/"><span class="tag">Vue</span> <span class="tag is-grey">8</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Vuex/"><span class="tag">Vuex</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/WSGI/"><span class="tag">WSGI</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Web/"><span class="tag">Web</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Word-Cut/"><span class="tag">Word Cut</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/aliyun/"><span class="tag">aliyun</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/auth/"><span class="tag">auth</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/babel/"><span class="tag">babel</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/certbot/"><span class="tag">certbot</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/decision-tree/"><span class="tag">decision tree</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/homebrew/"><span class="tag">homebrew</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/jwt/"><span class="tag">jwt</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/keystone/"><span class="tag">keystone</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/loader/"><span class="tag">loader</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/mathematics/"><span class="tag">mathematics</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/migrate/"><span class="tag">migrate</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/openstack/"><span class="tag">openstack</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/pdf2html/"><span class="tag">pdf2html</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/pm2/"><span class="tag">pm2</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/singular-value-decomposition/"><span class="tag">singular value decomposition</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/vue-router/"><span class="tag">vue-router</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/vue-ssr/"><span class="tag">vue-ssr</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/webpack/"><span class="tag">webpack</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E4%BD%8E%E9%80%9A%E6%BB%A4%E6%B3%A2%E5%99%A8/"><span class="tag">低通滤波器</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%85%A5%E9%97%A8/"><span class="tag">入门</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%85%A8%E5%B1%80%E5%8F%98%E9%87%8F/"><span class="tag">全局变量</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%85%A8%E5%B1%80%E5%AF%B9%E8%B1%A1/"><span class="tag">全局对象</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%85%A8%E6%A0%88/"><span class="tag">全栈</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%85%AC%E5%BC%8F/"><span class="tag">公式</span> <span class="tag is-grey">3</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%86%B3%E7%AD%96%E6%A0%91/"><span class="tag">决策树</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%87%BD%E6%95%B0/"><span class="tag">函数</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%88%86%E7%B1%BB%E5%99%A8/"><span class="tag">分类器</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%8A%A0%E9%80%9F/"><span class="tag">加速</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%8C%B9%E9%85%8D%E6%BB%A4%E6%B3%A2%E8%BE%B9%E7%BC%98%E6%A3%80%E6%B5%8B/"><span class="tag">匹配滤波边缘检测</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%8D%B7%E7%A7%AF/"><span class="tag">卷积</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%8D%B7%E7%A7%AF%E6%A0%B8/"><span class="tag">卷积核</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%8E%9F%E5%9E%8B%E9%93%BE/"><span class="tag">原型链</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%8F%8D%E5%90%91%E4%BC%A0%E6%92%AD/"><span class="tag">反向传播</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%8F%98%E9%87%8F%E7%B1%BB%E5%9E%8B/"><span class="tag">变量类型</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%AE%98%E6%96%B9%E7%A4%BA%E4%BE%8B/"><span class="tag">官方示例</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%AF%B9%E5%81%B6%E5%BD%A2%E5%BC%8F/"><span class="tag">对偶形式</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%AF%B9%E8%B1%A1/"><span class="tag">对象</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E5%B9%B3%E7%A7%BB%E5%92%8C%E6%9F%A5%E5%88%86%E8%BE%B9%E7%BC%98%E6%A3%80%E6%B5%8B/"><span class="tag">平移和查分边缘检测</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%8B%89%E6%A0%BC%E6%9C%97%E6%97%A5%E4%B9%98%E5%AD%90%E6%B3%95/"><span class="tag">拉格朗日乘子法</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%8E%A8%E5%AF%BC/"><span class="tag">推导</span> <span class="tag is-grey">3</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%8F%90%E4%BA%A4%E9%98%B6%E6%AE%B5/"><span class="tag">提交阶段</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%9C%80%E5%A4%A7%E4%BC%BC%E7%84%B6%E4%BC%B0%E8%AE%A1/"><span class="tag">最大似然估计</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E4%BC%B0%E8%AE%A1/"><span class="tag">最小二乘估计</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95/"><span class="tag">最小二乘法</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%9C%B4%E7%B4%A0%E8%B4%9D%E5%8F%B6%E6%96%AF/"><span class="tag">朴素贝叶斯</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/"><span class="tag">机器学习</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%9D%A1%E4%BB%B6%E6%A6%82%E7%8E%87/"><span class="tag">条件概率</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%A2%AF%E5%BA%A6%E4%B8%8B%E9%99%8D/"><span class="tag">梯度下降</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%A2%AF%E5%BA%A6%E6%96%B9%E5%90%91%E8%BE%B9%E7%BC%98%E6%A3%80%E6%B5%8B/"><span class="tag">梯度方向边缘检测</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%A6%82%E5%BF%B5/"><span class="tag">概念</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%A6%82%E7%8E%87/"><span class="tag">概率</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%B1%82%E5%AF%BC/"><span class="tag">求导</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%B5%81%E7%A8%8B/"><span class="tag">流程</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E7%86%B5/"><span class="tag">熵</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/"><span class="tag">生命周期</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E7%9F%A9%E9%98%B5/"><span class="tag">矩阵</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"><span class="tag">神经网络</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E7%A7%81%E6%9C%89%E5%AF%B9%E8%B1%A1/"><span class="tag">私有对象</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E7%B1%BB/"><span class="tag">类</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92/"><span class="tag">线性回归</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E8%81%94%E5%90%88%E6%A6%82%E7%8E%87/"><span class="tag">联合概率</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E8%B4%9D%E5%8F%B6%E6%96%AF%E5%88%A4%E5%AE%9A%E5%87%86%E5%88%99/"><span class="tag">贝叶斯判定准则</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E8%BE%B9%E7%BC%98%E6%A3%80%E6%B5%8B/"><span class="tag">边缘检测</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E8%BE%B9%E9%99%85%E6%A6%82%E7%8E%87/"><span class="tag">边际概率</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E9%97%AD%E5%8C%85/"><span class="tag">闭包</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E9%97%B4%E9%9A%94/"><span class="tag">间隔</span> <span class="tag is-grey">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E9%AB%98%E6%96%AF%E5%88%86%E5%B8%83/"><span class="tag">高斯分布</span> <span class="tag is-grey">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E9%AB%98%E9%80%9A%E6%BB%A4%E6%B3%A2%E5%99%A8/"><span class="tag">高通滤波器</span> <span class="tag is-grey">1</span></a></div></div></div></div></div></div></div></div></div></section><footer class="footer"><div class="container"><div class="level"><div class="level-start has-text-centered-mobile"><a class="footer-logo is-block has-mb-6" href="/"><img src="https://imgs.borgor.cn/imgs20190625111723.jpg" alt="Python面向对象基础" height="28"></a><p class="is-size-7">&copy; 2017-2019 Cyrusky&nbsp; Powered by <a href="https://hexo.io/" target="_blank">Hexo</a> & <a href="https://github.com/ppoffice/hexo-theme-icarus" target="_blank">Icarus</a><br><span id="busuanzi_container_site_uv">共<span id="busuanzi_value_site_uv">0</span>个访客</span><br><a target="_blank" href="https://icp.chinaz.com/info?q=borgor.cn">陇ICP备19002255号</a></p></div><div class="level-end"><div class="field has-addons is-flex-center-mobile has-mt-5-mobile is-flex-wrap is-flex-middle"><p class="control"><a class="button is-white is-large" target="_blank" title="Creative Commons" href="https://creativecommons.org/"><i class="fab fa-creative-commons"></i></a></p><p class="control"><a class="button is-white is-large" target="_blank" title="Attribution 4.0 International" href="https://creativecommons.org/licenses/by/4.0/"><i class="fab fa-creative-commons-by"></i></a></p><p class="control"><a class="button is-white is-large" target="_blank" title="Download on GitHub" href="https://github.com/ppoffice/hexo-theme-icarus"><i class="fab fa-github"></i></a></p></div></div></div></div></footer><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment-with-locales.min.js"></script><script>moment.locale("zh-CN")</script><script src="/js/animation.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.6.8/js/lightgallery.min.js" defer></script><script src="https://cdnjs.cloudflare.com/ajax/libs/justifiedGallery/3.7.0/js/jquery.justifiedGallery.min.js" defer></script><script src="/js/gallery.js" defer></script><div id="outdated"><h6>Your browser is out-of-date!</h6><p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/" target="_blank" rel="noopener">Update my browser now</a></p><p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p></div><script src="https://cdnjs.cloudflare.com/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.js" defer></script><script>document.addEventListener("DOMContentLoaded",function(){outdatedBrowser({bgColor:"#f25648",color:"#ffffff",lowerThan:"flex"})})</script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" defer></script><script>document.addEventListener("DOMContentLoaded",function(){MathJax.Hub.Config({"HTML-CSS":{matchFontHeight:!1},SVG:{matchFontHeight:!1},CommonHTML:{matchFontHeight:!1},tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}})})</script><a id="back-to-top" title="回到顶端" href="javascript:;" target="_blank" rel="noopener"><i class="fas fa-chevron-up"></i></a><script src="/js/back-to-top.js" defer></script><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" defer></script><script src="/js/clipboard.js" defer></script><script src="/js/main.js" defer></script><div class="searchbox ins-search"><div class="searchbox-container ins-search-container"><div class="searchbox-input-wrapper"><input type="text" class="searchbox-input ins-search-input" placeholder="想要查找什么..."> <span class="searchbox-close ins-close ins-selectable"><i class="fa fa-times-circle"></i></span></div><div class="searchbox-result-wrapper ins-section-wrapper"><div class="ins-section-container"></div></div></div></div><script>!function(T){var N={TRANSLATION:{POSTS:"文章",PAGES:"页面",CATEGORIES:"分类",TAGS:"标签",UNTITLED:"(无标题)"},CONTENT_URL:"/content.json"};T.INSIGHT_CONFIG=N}(window)</script><script src="/js/insight.js" defer></script><link rel="stylesheet" href="/css/search.css"><link rel="stylesheet" href="/css/insight.css"></body></html><!-- rebuild by neat -->